package com.sciencep.pro.admin.system.controller;


import com.sciencep.pro.common.domain.ResponseResult;
import com.sciencep.pro.core.domain.dto.dropdown.DeptSelectVO;
import com.sciencep.pro.core.domain.dto.dropdown.RoleSelectVO;
import com.sciencep.pro.core.domain.entity.Role;
import com.sciencep.pro.core.service.IDeptService;
import com.sciencep.pro.core.service.IRoleService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/dropdownBox")
public class DropdownBoxController {

    @Autowired
    IDeptService deptService;

    @Autowired
    IRoleService roleService;


    @GetMapping("/dept/list")
    @ApiOperation(value ="用户管理_下拉框部门",notes = "用户管理_下拉框部门")
    public ResponseResult<List<DeptSelectVO>> getDeptList(){

        return  new ResponseResult<List<DeptSelectVO>>().success(deptService.getDeptSelectVOList());
    }

    @GetMapping("/roleByGroupId/list")
    @ApiOperation(value ="用户管理_下拉框角色",notes = "用户管理_下拉框角色")
    public ResponseResult<List<RoleSelectVO>> getRoleByGroupIdList(@RequestParam String groupId){

        return  new ResponseResult<List<RoleSelectVO>>().success(roleService.getRoleSelectVOByGroupId(groupId));
    }

    @GetMapping("/role/list")
    @ApiOperation(value ="下拉框-角色",notes = "下拉框-角色")
    public ResponseResult<List<Role>> getRoleList(){
        return new ResponseResult<List<Role>>().success(roleService.list());
    }

}
